package com.meixiang.adapter.home;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.meixiang.R;
import com.meixiang.entity.training.TrainingDetails;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @author yinsujun  Created at 2016/6/24 13:50
 */
public class CosmeticTrainingCourseAdapter extends RecyclerView.Adapter<CosmeticTrainingCourseAdapter.ViewHolder> {

    private List<TrainingDetails.InstructionListBean> listBeen = new ArrayList<>();

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.activity_training_detail_course_list_item, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }


    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        TrainingDetails.InstructionListBean instructionListBean = listBeen.get(position);
        holder.tvTitle.setText(instructionListBean.getInstructionName()+":");
        holder.tvContent.setText(instructionListBean.getIndexValue());

    }

    @Override
    public int getItemCount() {
        return listBeen.size();
    }

    public void addAll(List<TrainingDetails.InstructionListBean> listBeen) {
        this.listBeen.addAll(listBeen);
        this.notifyDataSetChanged();

    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @Bind(R.id.training_detail_tv_title)
        TextView tvTitle;
        @Bind(R.id.training_detail_tv_content)
        TextView tvContent;
        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
